<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use app\portal\model\PortalCategoryModel;
use app\portal\service\PostService;

class ViewController extends HomeBaseController
{
    public function index()
    {        
        $data                  = $this->request->param();
        $portalCategoryModel = new PortalCategoryModel();
        $postService         = new PostService();
        $id = $data['id'] ?? '';
        $category = $portalCategoryModel->CategoryOne($data['cid']);
        
        $article = $postService->publishedPage($id);
        $publisPrevNext = $postService->publisPrevNextArticle($id,$data['cid']);
        $this->assign('article', $article);
        $this->assign('category', $category);
        $this->assign('publisPrevNext', $publisPrevNext);
        $listTpl = empty($category['one_tpl']) ? 'index' : $category['one_tpl'];
        return $this->fetch('/' . $listTpl);
    }

}
